package com.google.android.gms.internal;

import android.content.Context;
import android.location.Location;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.text.TextUtils;
import com.google.android.exoplayer2.source.chunk.ChunkedTrackBlacklistUtil;
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
import com.google.android.gms.ads.internal.zzbt;
import com.google.android.gms.common.internal.Hide;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.json.JSONException;
import org.json.JSONObject;

@Hide
@zzabh
public final class zzadn extends zzaco {
    private static final Object sLock = new Object();
    private static zzadn zzcwb;
    private final Context mContext;
    private final zzadm zzcwc;
    private final ScheduledExecutorService zzcwd = Executors.newSingleThreadScheduledExecutor();

    private zzadn(Context context, zzadm zzadm) {
        this.mContext = context;
        this.zzcwc = zzadm;
    }

    private static zzacj zza(Context context, zzadm zzadm, zzacf zzacf, ScheduledExecutorService scheduledExecutorService) {
        String string;
        Context context2 = context;
        zzadm zzadm2 = zzadm;
        zzacf zzacf2 = zzacf;
        ScheduledExecutorService scheduledExecutorService2 = scheduledExecutorService;
        zzahw.zzby("Starting ad request from service using: google.afma.request.getAdDictionary");
        zzov zzov = new zzov(((Boolean) zzlc.zzio().zzd(zzoi.zzbne)).booleanValue(), "load_ad", zzacf2.zzaud.zzbia);
        if (zzacf2.versionCode > 10 && zzacf2.zzcsl != -1) {
            zzov.zza(zzov.zzd(zzacf2.zzcsl), "cts");
        }
        zzot zzjo = zzov.zzjo();
        zzalt<V> zza = zzali.zza(zzadm2.zzcvy.zzi(context2), ((Long) zzlc.zzio().zzd(zzoi.zzbtv)).longValue(), TimeUnit.MILLISECONDS, scheduledExecutorService2);
        zzalt<V> zza2 = zzali.zza(zzadm2.zzcvx.zzp(context2), ((Long) zzlc.zzio().zzd(zzoi.zzbra)).longValue(), TimeUnit.MILLISECONDS, scheduledExecutorService2);
        zzalt<String> zzbz = zzadm2.zzcvs.zzbz(zzacf2.zzcrw.packageName);
        zzalt<String> zza3 = zzadm2.zzcvz.zza(zzacf2.zzcrx, zzacf2.zzcrw);
        Future<zzaea> zzo = zzbt.zzew().zzo(context2);
        zzalt zzh = zzali.zzh(null);
        Bundle bundle = zzacf2.zzcrv.extras;
        boolean z = (bundle == null || bundle.getString("_ad") == null) ? false : true;
        if (zzacf2.zzcsr && !z) {
            zzh = zzadm2.zzcvv.zza(zzacf2.applicationInfo);
        }
        zzalt zza4 = zzali.zza(zzh, ((Long) zzlc.zzio().zzd(zzoi.zzbte)).longValue(), TimeUnit.MILLISECONDS, scheduledExecutorService2);
        zzalt<V> zzh2 = zzali.zzh(null);
        if (((Boolean) zzlc.zzio().zzd(zzoi.zzbpd)).booleanValue()) {
            zzh2 = zzali.zza(zzadm2.zzcvz.zzac(context2), ((Long) zzlc.zzio().zzd(zzoi.zzbpe)).longValue(), TimeUnit.MILLISECONDS, scheduledExecutorService2);
        }
        Bundle bundle2 = (zzacf2.versionCode < 4 || zzacf2.zzcsc == null) ? null : zzacf2.zzcsc;
        ((Boolean) zzlc.zzio().zzd(zzoi.zzbnu)).booleanValue();
        zzbt.zzel();
        if (zzaij.zzd(context2, context.getPackageName(), "android.permission.ACCESS_NETWORK_STATE") && ((ConnectivityManager) context2.getSystemService("connectivity")).getActiveNetworkInfo() == null) {
            zzahw.zzby("Device is offline.");
        }
        String uuid = zzacf2.versionCode >= 7 ? zzacf2.zzcsi : UUID.randomUUID().toString();
        new zzadt(context2, uuid, zzacf2.applicationInfo.packageName);
        if (zzacf2.zzcrv.extras != null && (string = zzacf2.zzcrv.extras.getString("_ad")) != null) {
            return zzads.zza(context2, zzacf2, string);
        }
        List<String> zzf = zzadm2.zzcvt.zzf(zzacf2.zzcsj);
        zzov zzov2 = zzov;
        zzot zzot = zzjo;
        String str = uuid;
        Bundle bundle3 = (Bundle) zzali.zza(zza, null, ((Long) zzlc.zzio().zzd(zzoi.zzbtv)).longValue(), TimeUnit.MILLISECONDS);
        zzaek zzaek = (zzaek) zzali.zza(zza2, null);
        Location location = (Location) zzali.zza(zza4, null);
        AdvertisingIdClient.Info info = (AdvertisingIdClient.Info) zzali.zza(zzh2, null);
        String str2 = (String) zzali.zza(zza3, null);
        String str3 = (String) zzali.zza(zzbz, null);
        zzaea zzaea = (zzaea) zzali.zza(zzo, null);
        if (zzaea == null) {
            zzahw.zzcz("Error fetching device info. This is not recoverable.");
            return new zzacj(0);
        }
        zzadl zzadl = new zzadl();
        zzadl.zzcvm = zzacf2;
        zzadl.zzcvn = zzaea;
        zzadl.zzcvj = zzaek;
        zzadl.zzbhd = location;
        zzadl.zzcvi = bundle3;
        zzadl.zzcrx = str2;
        zzadl.zzcvl = info;
        if (zzf == null) {
            zzadl.zzcsj.clear();
        }
        zzadl.zzcsj = zzf;
        zzadl.zzcsc = bundle2;
        zzadl.zzcvk = str3;
        zzadl.zzcvo = zzadm2.zzcvr.zze(context2);
        zzadl.zzcvp = zzadm2.zzcvp;
        JSONObject zza5 = zzads.zza(context2, zzadl);
        if (zza5 == null) {
            return new zzacj(0);
        }
        if (zzacf2.versionCode < 7) {
            try {
                zza5.put("request_id", str);
            } catch (JSONException unused) {
            }
        }
        zza5.toString();
        zzov zzov3 = zzov2;
        zzot zzot2 = zzot;
        zzov3.zza(zzot2, "arc");
        zzov3.zzjo();
        ScheduledExecutorService scheduledExecutorService3 = scheduledExecutorService;
        zzalt<V> zza6 = zzali.zza(zzali.zza(zzadm2.zzcwa.zzoe().zzf(zza5), zzado.zzaoy, (Executor) scheduledExecutorService3), 10, TimeUnit.SECONDS, scheduledExecutorService3);
        zzalt<Void> zzon = zzadm2.zzcvu.zzon();
        if (zzon != null) {
            zzalg.zza(zzon, "AdRequestServiceImpl.loadAd.flags");
        }
        zzadz zzadz = (zzadz) zzali.zza(zza6, null);
        if (zzadz == null) {
            return new zzacj(0);
        }
        if (zzadz.getErrorCode() != -2) {
            return new zzacj(zzadz.getErrorCode());
        }
        zzov3.zzjr();
        zzacj zza7 = !TextUtils.isEmpty(zzadz.zzok()) ? zzads.zza(context2, zzacf2, zzadz.zzok()) : null;
        if (zza7 == null && !TextUtils.isEmpty(zzadz.getUrl())) {
            zza7 = zza(zzacf2, context2, zzacf2.zzatz.zzcu, zzadz.getUrl(), str3, zzadz, zzov3, zzadm2);
        }
        if (zza7 == null) {
            zza7 = new zzacj(0);
        }
        zzov3.zza(zzot2, "tts");
        zza7.zzcub = zzov3.zzjp();
        return zza7;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:43:0x00d6, code lost:
        r1 = r7.toString();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:45:?, code lost:
        r7 = new java.io.InputStreamReader(r12.getInputStream());
     */
    /* JADX WARNING: Code restructure failed: missing block: B:47:?, code lost:
        com.google.android.gms.ads.internal.zzbt.zzel();
        r11 = com.google.android.gms.internal.zzaij.zza(r7);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:49:?, code lost:
        com.google.android.gms.common.util.zzp.closeQuietly(r7);
        r10.zzcw(r11);
        zza(r1, (java.util.Map<java.lang.String, java.util.List<java.lang.String>>) r14, r11, r4);
        r6.zza(r1, r14, r11);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:50:0x00f6, code lost:
        if (r2 == null) goto L_0x0101;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:51:0x00f8, code lost:
        r2.zza(r5, "ufe");
     */
    /* JADX WARNING: Code restructure failed: missing block: B:52:0x0101, code lost:
        r1 = r6.zza(r8, r23.zzol());
     */
    /* JADX WARNING: Code restructure failed: missing block: B:54:?, code lost:
        r12.disconnect();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:55:0x010c, code lost:
        if (r3 == null) goto L_0x0113;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:56:0x010e, code lost:
        r3.zzcvw.zzop();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:57:0x0113, code lost:
        return r1;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:58:0x0114, code lost:
        r0 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:59:0x0115, code lost:
        r1 = r0;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:60:0x0117, code lost:
        r0 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:61:0x0118, code lost:
        r1 = r0;
        r7 = null;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:63:?, code lost:
        com.google.android.gms.common.util.zzp.closeQuietly(r7);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:64:0x011d, code lost:
        throw r1;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:71:0x0138, code lost:
        com.google.android.gms.internal.zzahw.zzcz("No location header to follow redirect.");
        r1 = new com.google.android.gms.internal.zzacj(0);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:73:?, code lost:
        r12.disconnect();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:74:0x0146, code lost:
        if (r3 == null) goto L_0x014d;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:75:0x0148, code lost:
        r3.zzcvw.zzop();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:76:0x014d, code lost:
        return r1;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:80:0x0167, code lost:
        com.google.android.gms.internal.zzahw.zzcz("Too many redirects.");
        r1 = new com.google.android.gms.internal.zzacj(0);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:82:?, code lost:
        r12.disconnect();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:83:0x0175, code lost:
        if (r3 == null) goto L_0x017c;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:84:0x0177, code lost:
        r3.zzcvw.zzop();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:85:0x017c, code lost:
        return r1;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static com.google.android.gms.internal.zzacj zza(com.google.android.gms.internal.zzacf r18, android.content.Context r19, java.lang.String r20, java.lang.String r21, java.lang.String r22, com.google.android.gms.internal.zzadz r23, com.google.android.gms.internal.zzov r24, com.google.android.gms.internal.zzadm r25) {
        /*
            r1 = r18
            r2 = r24
            r3 = r25
            if (r2 == 0) goto L_0x000d
            com.google.android.gms.internal.zzot r5 = r24.zzjo()
            goto L_0x000e
        L_0x000d:
            r5 = 0
        L_0x000e:
            com.google.android.gms.internal.zzadx r6 = new com.google.android.gms.internal.zzadx     // Catch:{ IOException -> 0x01c4 }
            java.lang.String r7 = r23.zzoh()     // Catch:{ IOException -> 0x01c4 }
            r6.<init>(r1, r7)     // Catch:{ IOException -> 0x01c4 }
            java.lang.String r7 = "AdRequestServiceImpl: Sending request: "
            java.lang.String r8 = java.lang.String.valueOf(r21)     // Catch:{ IOException -> 0x01c4 }
            int r9 = r8.length()     // Catch:{ IOException -> 0x01c4 }
            if (r9 == 0) goto L_0x0028
            java.lang.String r7 = r7.concat(r8)     // Catch:{ IOException -> 0x01c4 }
            goto L_0x002e
        L_0x0028:
            java.lang.String r8 = new java.lang.String     // Catch:{ IOException -> 0x01c4 }
            r8.<init>(r7)     // Catch:{ IOException -> 0x01c4 }
            r7 = r8
        L_0x002e:
            com.google.android.gms.internal.zzahw.zzby(r7)     // Catch:{ IOException -> 0x01c4 }
            java.net.URL r7 = new java.net.URL     // Catch:{ IOException -> 0x01c4 }
            r8 = r21
            r7.<init>(r8)     // Catch:{ IOException -> 0x01c4 }
            com.google.android.gms.common.util.zze r8 = com.google.android.gms.ads.internal.zzbt.zzes()     // Catch:{ IOException -> 0x01c4 }
            long r8 = r8.elapsedRealtime()     // Catch:{ IOException -> 0x01c4 }
            r10 = 0
            r11 = r10
        L_0x0042:
            if (r3 == 0) goto L_0x0049
            com.google.android.gms.internal.zzaei r12 = r3.zzcvw     // Catch:{ IOException -> 0x01c4 }
            r12.zzoo()     // Catch:{ IOException -> 0x01c4 }
        L_0x0049:
            java.net.URLConnection r12 = r7.openConnection()     // Catch:{ IOException -> 0x01c4 }
            java.net.HttpURLConnection r12 = (java.net.HttpURLConnection) r12     // Catch:{ IOException -> 0x01c4 }
            com.google.android.gms.internal.zzaij r13 = com.google.android.gms.ads.internal.zzbt.zzel()     // Catch:{ all -> 0x01b7 }
            r14 = r19
            r15 = r20
            r13.zza((android.content.Context) r14, (java.lang.String) r15, (boolean) r10, (java.net.HttpURLConnection) r12)     // Catch:{ all -> 0x01b7 }
            boolean r13 = android.text.TextUtils.isEmpty(r22)     // Catch:{ all -> 0x01b7 }
            if (r13 != 0) goto L_0x006e
            boolean r13 = r23.zzoj()     // Catch:{ all -> 0x01b7 }
            if (r13 == 0) goto L_0x006e
            java.lang.String r13 = "x-afma-drt-cookie"
            r10 = r22
            r12.addRequestProperty(r13, r10)     // Catch:{ all -> 0x01b7 }
            goto L_0x0070
        L_0x006e:
            r10 = r22
        L_0x0070:
            java.lang.String r13 = r1.zzcss     // Catch:{ all -> 0x01b7 }
            boolean r16 = android.text.TextUtils.isEmpty(r13)     // Catch:{ all -> 0x01b7 }
            if (r16 != 0) goto L_0x0082
            java.lang.String r4 = "Sending webview cookie in ad request header."
            com.google.android.gms.internal.zzahw.zzby(r4)     // Catch:{ all -> 0x01b7 }
            java.lang.String r4 = "Cookie"
            r12.addRequestProperty(r4, r13)     // Catch:{ all -> 0x01b7 }
        L_0x0082:
            if (r23 == 0) goto L_0x00b8
            java.lang.String r4 = r23.zzoi()     // Catch:{ all -> 0x01b7 }
            boolean r4 = android.text.TextUtils.isEmpty(r4)     // Catch:{ all -> 0x01b7 }
            if (r4 != 0) goto L_0x00b8
            r4 = 1
            r12.setDoOutput(r4)     // Catch:{ all -> 0x01b7 }
            java.lang.String r4 = r23.zzoi()     // Catch:{ all -> 0x01b7 }
            byte[] r4 = r4.getBytes()     // Catch:{ all -> 0x01b7 }
            int r10 = r4.length     // Catch:{ all -> 0x01b7 }
            r12.setFixedLengthStreamingMode(r10)     // Catch:{ all -> 0x01b7 }
            java.io.BufferedOutputStream r10 = new java.io.BufferedOutputStream     // Catch:{ all -> 0x00b1 }
            java.io.OutputStream r14 = r12.getOutputStream()     // Catch:{ all -> 0x00b1 }
            r10.<init>(r14)     // Catch:{ all -> 0x00b1 }
            r10.write(r4)     // Catch:{ all -> 0x00ae }
            com.google.android.gms.common.util.zzp.closeQuietly(r10)     // Catch:{ all -> 0x01b7 }
            goto L_0x00b9
        L_0x00ae:
            r0 = move-exception
            r1 = r0
            goto L_0x00b4
        L_0x00b1:
            r0 = move-exception
            r1 = r0
            r10 = 0
        L_0x00b4:
            com.google.android.gms.common.util.zzp.closeQuietly(r10)     // Catch:{ all -> 0x01b7 }
            throw r1     // Catch:{ all -> 0x01b7 }
        L_0x00b8:
            r4 = 0
        L_0x00b9:
            com.google.android.gms.internal.zzaks r10 = new com.google.android.gms.internal.zzaks     // Catch:{ all -> 0x01b7 }
            java.lang.String r14 = r1.zzcsi     // Catch:{ all -> 0x01b7 }
            r10.<init>(r14)     // Catch:{ all -> 0x01b7 }
            r10.zza((java.net.HttpURLConnection) r12, (byte[]) r4)     // Catch:{ all -> 0x01b7 }
            int r4 = r12.getResponseCode()     // Catch:{ all -> 0x01b7 }
            java.util.Map r14 = r12.getHeaderFields()     // Catch:{ all -> 0x01b7 }
            r10.zza((java.net.HttpURLConnection) r12, (int) r4)     // Catch:{ all -> 0x01b7 }
            r1 = 200(0xc8, float:2.8E-43)
            r15 = 300(0x12c, float:4.2E-43)
            if (r4 < r1) goto L_0x011e
            if (r4 >= r15) goto L_0x011e
            java.lang.String r1 = r7.toString()     // Catch:{ all -> 0x01b7 }
            java.io.InputStreamReader r7 = new java.io.InputStreamReader     // Catch:{ all -> 0x0117 }
            java.io.InputStream r11 = r12.getInputStream()     // Catch:{ all -> 0x0117 }
            r7.<init>(r11)     // Catch:{ all -> 0x0117 }
            com.google.android.gms.ads.internal.zzbt.zzel()     // Catch:{ all -> 0x0114 }
            java.lang.String r11 = com.google.android.gms.internal.zzaij.zza((java.io.InputStreamReader) r7)     // Catch:{ all -> 0x0114 }
            com.google.android.gms.common.util.zzp.closeQuietly(r7)     // Catch:{ all -> 0x01b7 }
            r10.zzcw(r11)     // Catch:{ all -> 0x01b7 }
            zza((java.lang.String) r1, (java.util.Map<java.lang.String, java.util.List<java.lang.String>>) r14, (java.lang.String) r11, (int) r4)     // Catch:{ all -> 0x01b7 }
            r6.zza(r1, r14, r11)     // Catch:{ all -> 0x01b7 }
            if (r2 == 0) goto L_0x0101
            java.lang.String r1 = "ufe"
            java.lang.String[] r1 = new java.lang.String[]{r1}     // Catch:{ all -> 0x01b7 }
            r2.zza(r5, r1)     // Catch:{ all -> 0x01b7 }
        L_0x0101:
            boolean r1 = r23.zzol()     // Catch:{ all -> 0x01b7 }
            com.google.android.gms.internal.zzacj r1 = r6.zza((long) r8, (boolean) r1)     // Catch:{ all -> 0x01b7 }
            r12.disconnect()     // Catch:{ IOException -> 0x01c4 }
            if (r3 == 0) goto L_0x0113
            com.google.android.gms.internal.zzaei r2 = r3.zzcvw     // Catch:{ IOException -> 0x01c4 }
            r2.zzop()     // Catch:{ IOException -> 0x01c4 }
        L_0x0113:
            return r1
        L_0x0114:
            r0 = move-exception
            r1 = r0
            goto L_0x011a
        L_0x0117:
            r0 = move-exception
            r1 = r0
            r7 = 0
        L_0x011a:
            com.google.android.gms.common.util.zzp.closeQuietly(r7)     // Catch:{ all -> 0x01b7 }
            throw r1     // Catch:{ all -> 0x01b7 }
        L_0x011e:
            java.lang.String r1 = r7.toString()     // Catch:{ all -> 0x01b7 }
            r7 = 0
            zza((java.lang.String) r1, (java.util.Map<java.lang.String, java.util.List<java.lang.String>>) r14, (java.lang.String) r7, (int) r4)     // Catch:{ all -> 0x01b7 }
            if (r4 < r15) goto L_0x0190
            r1 = 400(0x190, float:5.6E-43)
            if (r4 >= r1) goto L_0x0190
            java.lang.String r1 = "Location"
            java.lang.String r1 = r12.getHeaderField(r1)     // Catch:{ all -> 0x01b7 }
            boolean r4 = android.text.TextUtils.isEmpty(r1)     // Catch:{ all -> 0x01b7 }
            if (r4 == 0) goto L_0x014e
            java.lang.String r1 = "No location header to follow redirect."
            com.google.android.gms.internal.zzahw.zzcz(r1)     // Catch:{ all -> 0x01b7 }
            com.google.android.gms.internal.zzacj r1 = new com.google.android.gms.internal.zzacj     // Catch:{ all -> 0x01b7 }
            r2 = 0
            r1.<init>(r2)     // Catch:{ all -> 0x01b7 }
            r12.disconnect()     // Catch:{ IOException -> 0x01c4 }
            if (r3 == 0) goto L_0x014d
            com.google.android.gms.internal.zzaei r2 = r3.zzcvw     // Catch:{ IOException -> 0x01c4 }
            r2.zzop()     // Catch:{ IOException -> 0x01c4 }
        L_0x014d:
            return r1
        L_0x014e:
            java.net.URL r4 = new java.net.URL     // Catch:{ all -> 0x01b7 }
            r4.<init>(r1)     // Catch:{ all -> 0x01b7 }
            r1 = 1
            int r11 = r11 + r1
            com.google.android.gms.internal.zzny<java.lang.Integer> r1 = com.google.android.gms.internal.zzoi.zzbvf     // Catch:{ all -> 0x01b7 }
            com.google.android.gms.internal.zzog r10 = com.google.android.gms.internal.zzlc.zzio()     // Catch:{ all -> 0x01b7 }
            java.lang.Object r1 = r10.zzd(r1)     // Catch:{ all -> 0x01b7 }
            java.lang.Integer r1 = (java.lang.Integer) r1     // Catch:{ all -> 0x01b7 }
            int r1 = r1.intValue()     // Catch:{ all -> 0x01b7 }
            if (r11 <= r1) goto L_0x017d
            java.lang.String r1 = "Too many redirects."
            com.google.android.gms.internal.zzahw.zzcz(r1)     // Catch:{ all -> 0x01b7 }
            com.google.android.gms.internal.zzacj r1 = new com.google.android.gms.internal.zzacj     // Catch:{ all -> 0x01b7 }
            r2 = 0
            r1.<init>(r2)     // Catch:{ all -> 0x01b7 }
            r12.disconnect()     // Catch:{ IOException -> 0x01c4 }
            if (r3 == 0) goto L_0x017c
            com.google.android.gms.internal.zzaei r2 = r3.zzcvw     // Catch:{ IOException -> 0x01c4 }
            r2.zzop()     // Catch:{ IOException -> 0x01c4 }
        L_0x017c:
            return r1
        L_0x017d:
            r6.zzo(r14)     // Catch:{ all -> 0x01b7 }
            r12.disconnect()     // Catch:{ IOException -> 0x01c4 }
            if (r3 == 0) goto L_0x018a
            com.google.android.gms.internal.zzaei r1 = r3.zzcvw     // Catch:{ IOException -> 0x01c4 }
            r1.zzop()     // Catch:{ IOException -> 0x01c4 }
        L_0x018a:
            r7 = r4
            r1 = r18
            r10 = 0
            goto L_0x0042
        L_0x0190:
            r1 = 46
            java.lang.StringBuilder r2 = new java.lang.StringBuilder     // Catch:{ all -> 0x01b7 }
            r2.<init>(r1)     // Catch:{ all -> 0x01b7 }
            java.lang.String r1 = "Received error HTTP response code: "
            r2.append(r1)     // Catch:{ all -> 0x01b7 }
            r2.append(r4)     // Catch:{ all -> 0x01b7 }
            java.lang.String r1 = r2.toString()     // Catch:{ all -> 0x01b7 }
            com.google.android.gms.internal.zzahw.zzcz(r1)     // Catch:{ all -> 0x01b7 }
            com.google.android.gms.internal.zzacj r1 = new com.google.android.gms.internal.zzacj     // Catch:{ all -> 0x01b7 }
            r2 = 0
            r1.<init>(r2)     // Catch:{ all -> 0x01b7 }
            r12.disconnect()     // Catch:{ IOException -> 0x01c4 }
            if (r3 == 0) goto L_0x01b6
            com.google.android.gms.internal.zzaei r2 = r3.zzcvw     // Catch:{ IOException -> 0x01c4 }
            r2.zzop()     // Catch:{ IOException -> 0x01c4 }
        L_0x01b6:
            return r1
        L_0x01b7:
            r0 = move-exception
            r1 = r0
            r12.disconnect()     // Catch:{ IOException -> 0x01c4 }
            if (r3 == 0) goto L_0x01c3
            com.google.android.gms.internal.zzaei r2 = r3.zzcvw     // Catch:{ IOException -> 0x01c4 }
            r2.zzop()     // Catch:{ IOException -> 0x01c4 }
        L_0x01c3:
            throw r1     // Catch:{ IOException -> 0x01c4 }
        L_0x01c4:
            r0 = move-exception
            r1 = r0
            java.lang.String r2 = "Error while connecting to ad server: "
            java.lang.String r1 = r1.getMessage()
            java.lang.String r1 = java.lang.String.valueOf(r1)
            int r3 = r1.length()
            if (r3 == 0) goto L_0x01db
            java.lang.String r1 = r2.concat(r1)
            goto L_0x01e0
        L_0x01db:
            java.lang.String r1 = new java.lang.String
            r1.<init>(r2)
        L_0x01e0:
            com.google.android.gms.internal.zzahw.zzcz(r1)
            com.google.android.gms.internal.zzacj r1 = new com.google.android.gms.internal.zzacj
            r2 = 2
            r1.<init>(r2)
            return r1
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.internal.zzadn.zza(com.google.android.gms.internal.zzacf, android.content.Context, java.lang.String, java.lang.String, java.lang.String, com.google.android.gms.internal.zzadz, com.google.android.gms.internal.zzov, com.google.android.gms.internal.zzadm):com.google.android.gms.internal.zzacj");
    }

    public static zzadn zza(Context context, zzadm zzadm) {
        zzadn zzadn;
        synchronized (sLock) {
            if (zzcwb == null) {
                if (context.getApplicationContext() != null) {
                    context = context.getApplicationContext();
                }
                zzoi.initialize(context);
                zzcwb = new zzadn(context, zzadm);
                if (context.getApplicationContext() != null) {
                    zzbt.zzel().zzai(context);
                }
                zzahu.zzaf(context);
            }
            zzadn = zzcwb;
        }
        return zzadn;
    }

    private static void zza(String str, Map<String, List<String>> map, String str2, int i) {
        if (zzahw.zzae(2)) {
            StringBuilder sb = new StringBuilder(39 + String.valueOf(str).length());
            sb.append("Http Response: {\n  URL:\n    ");
            sb.append(str);
            sb.append("\n  Headers:");
            zzahw.v(sb.toString());
            if (map != null) {
                for (String next : map.keySet()) {
                    StringBuilder sb2 = new StringBuilder(5 + String.valueOf(next).length());
                    sb2.append("    ");
                    sb2.append(next);
                    sb2.append(":");
                    zzahw.v(sb2.toString());
                    for (String valueOf : map.get(next)) {
                        String valueOf2 = String.valueOf(valueOf);
                        zzahw.v(valueOf2.length() != 0 ? "      ".concat(valueOf2) : new String("      "));
                    }
                }
            }
            zzahw.v("  Body:");
            if (str2 != null) {
                int i2 = 0;
                while (i2 < Math.min(str2.length(), DefaultOggSeeker.MATCH_BYTE_RANGE)) {
                    int i3 = i2 + 1000;
                    zzahw.v(str2.substring(i2, Math.min(str2.length(), i3)));
                    i2 = i3;
                }
            } else {
                zzahw.v("    null");
            }
            StringBuilder sb3 = new StringBuilder(34);
            sb3.append("  Response Code:\n    ");
            sb3.append(i);
            sb3.append("\n}");
            zzahw.v(sb3.toString());
        }
    }

    public final void zza(zzacf zzacf, zzacq zzacq) {
        zzbt.zzep().zzd(this.mContext, zzacf.zzatz);
        zzalt<Void> zzb = zzaid.zzb(new zzadp(this, zzacf, zzacq));
        zzbt.zzfa().zzrt();
        zzbt.zzfa().getHandler().postDelayed(new zzadq(this, zzb), ChunkedTrackBlacklistUtil.DEFAULT_TRACK_BLACKLIST_MS);
    }

    public final void zza(zzacy zzacy, zzact zzact) {
        zzahw.v("Nonagon code path entered in octagon");
        throw new IllegalArgumentException();
    }

    public final zzacj zzb(zzacf zzacf) {
        return zza(this.mContext, this.zzcwc, zzacf, this.zzcwd);
    }
}
